//jquery扩展方法
$.extend({
  //显示界面
  showPanel(el, type, callback) {
      let jqel = $(el)
      if (jqel.hasClass('animated')) { return false }
      let animateClass = 'animated ' + type
      jqel.addClass(animateClass).show()
      setTimeout(function () {
          jqel.removeClass(animateClass)
          typeof callback == 'function' && callback()
      }, 800)
  },
  //隐藏界面
  hidePanel(el, type, callback) {
      let jqel = $(el)
      if (jqel.hasClass('animated')) { return false }
      let animateClass = 'animated ' + type
      jqel.addClass(animateClass)
      setTimeout(function () {
          jqel.hide().removeClass(animateClass)
          typeof callback == 'function' && callback()
      }, 800)
  },
  msgbox(content, title, btns) {
      content = content || '提示内容', title = title || '提示'
      let msgboxEl = $('#msgbox')
      let _btns = btns || { '确定': function () { msgboxEl.hide() } }
      this.render('#msgbox', { title: title, content: content, btns: _btns })
      msgboxEl.find('.msgbox-btns').children('div').each(function (idx, el) {
          $(el).on('click', function () {
              let callback = _btns[$(el).text()]
              typeof callback === 'function' && callback()
              msgboxEl.hide()
          })
      })
      msgboxEl.show()
  },
  loading() {
      let loadingEl = $('<div class="loading"><svg viewBox="25 25 50 50" class="circular"><circle cx="50" cy="50" r="20" fill="none" class="path"></circle></svg></div>');
      $('body').append(loadingEl);
      setTimeout(() => {
          this.loaded();
      }, 10000);
  },
  loaded() {
      $('body>.loading').remove();
  }
})